package cn.bytecollege.admin.dao;

import cn.bytecollege.common.dao.BaseDao;
import cn.bytecollege.common.entity.User;

import java.util.List;

public class UserDao extends BaseDao<User,Integer> {
    /**
     * 分页查询用户信息
     * @param pageIndex
     * @param pageSize
     * @return
     */
    public List<User> findUserByPage(int pageIndex,int pageSize) {
        String sql = "SELECT USER_ID,USERNAME,CREATE_TIME,USER_PHONENUMBER,USER_HEAD_PORTRAIT,user_nickname FROM USER LIMIT ?,?";
        Object[] objects = {(pageIndex-1)*pageSize,pageSize};
        return helper.executeQuery(sql,User.class,objects);
    }

    /**
     * 查询用户总数
     * @return
     */
    public int count(){
        String sql = "SELECT COUNT(*) FROM USER";
        return helper.executeScale(sql);
    }
}
